Checks and radios 路 Bootstrap v5.0 您所在的位置:网站首页 bootstrap aria-label Checks and radios 路 Bootstrap v5.0

Checks and radios 路 Bootstrap v5.0

2024-06-03 08:36| 来源: 网络整理| 查看: 265

View on GitHub Checks and radios

Create consistent cross-browser and cross-device checkboxes and radios with our completely rewritten checks component.

On this page Approach

Browser default checkboxes and radios are replaced with the help of .form-check, a series of classes for both input types that improves the layout and behavior of their HTML elements, that provide greater customization and cross browser consistency. Checkboxes are for selecting one or several options in a list, while radios are for selecting one option from many.

Structurally, our s and s are sibling elements as opposed to an within a . This is slightly more verbose as you must specify id and for attributes to relate the and . We use the sibling selector (~) for all our states, like :checked or :disabled. When combined with the .form-check-label class, we can easily style the text for each item based on the ’s state.

Our checks use custom Bootstrap icons to indicate checked or indeterminate states.

Checks Default checkbox Checked checkbox Indeterminate

Checkboxes can utilize the :indeterminate pseudo class when manually set via JavaScript (there is no available HTML attribute for specifying it).

Indeterminate checkbox Disabled

Add the disabled attribute and the associated s are automatically styled to match with a lighter color to help indicate the input’s state.

Disabled checkbox Disabled checked checkbox Radios Default radio Default checked radio Disabled

Add the disabled attribute and the associated s are automatically styled to match with a lighter color to help indicate the input’s state.

Disabled radio Disabled checked radio Switches

A switch has the markup of a custom checkbox but uses the .form-switch class to render a toggle switch. Switches also support the disabled attribute.

Default switch checkbox input Checked switch checkbox input Disabled switch checkbox input Disabled checked switch checkbox input Default (stacked)

By default, any number of checkboxes and radios that are immediate sibling will be vertically stacked and appropriately spaced with .form-check.

Default checkbox Disabled checkbox Default radio Second default radio Disabled radio Inline

Group checkboxes or radios on the same horizontal row by adding .form-check-inline to any .form-check.

1 2 3 (disabled) 1 2 3 (disabled) Without labels

Omit the wrapping .form-check for checkboxes and radios that have no label text. Remember to still provide some form of accessible name for assistive technologies (for instance, using aria-label). See the forms overview accessibility section for details.

Toggle buttons

Create button-like checkboxes and radio buttons by using .btn styles rather than .form-check-label on the elements. These toggle buttons can further be grouped in a button group if needed.

Checkbox toggle buttons Single toggle Checked Disabled Visually, these checkbox toggle buttons are identical to the button plugin toggle buttons. However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as “checked”/“not checked” (since, despite their appearance, they are fundamentally still checkboxes), whereas the button plugin toggle buttons will be announced as “button”/“button pressed”. The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button. Radio toggle buttons Checked Radio Disabled Radio Outlined styles

Different variants of .btn, such at the various outlined styles, are supported.

Single toggle Checked Checked success radio Danger radio Sass Variables $form-check-input-width: 1em; $form-check-min-height: $font-size-base * $line-height-base; $form-check-padding-start: $form-check-input-width + .5em; $form-check-margin-bottom: .125rem; $form-check-label-color: null; $form-check-label-cursor: null; $form-check-transition: null; $form-check-input-active-filter: brightness(90%); $form-check-input-bg: $input-bg; $form-check-input-border: 1px solid rgba($black, .25); $form-check-input-border-radius: .25em; $form-check-radio-border-radius: 50%; $form-check-input-focus-border: $input-focus-border-color; $form-check-input-focus-box-shadow: $input-btn-focus-box-shadow; $form-check-input-checked-color: $component-active-color; $form-check-input-checked-bg-color: $component-active-bg; $form-check-input-checked-border-color: $form-check-input-checked-bg-color; $form-check-input-checked-bg-image: url("data:image/svg+xml,"); $form-check-radio-checked-bg-image: url("data:image/svg+xml,"); $form-check-input-indeterminate-color: $component-active-color; $form-check-input-indeterminate-bg-color: $component-active-bg; $form-check-input-indeterminate-border-color: $form-check-input-indeterminate-bg-color; $form-check-input-indeterminate-bg-image: url("data:image/svg+xml,"); $form-check-input-disabled-opacity: .5; $form-check-label-disabled-opacity: $form-check-input-disabled-opacity; $form-check-btn-check-disabled-opacity: $btn-disabled-opacity; $form-check-inline-margin-end: 1rem;


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有